package com.bw.heishou.Utilise;

import android.content.Context;
import android.content.SharedPreferences;

import com.bw.heishou.App;

public class SharedPreferencesUtilise {
    SharedPreferences.Editor edit;
    SharedPreferences sharedPreferences;

    public SharedPreferencesUtilise() {
        sharedPreferences = App.context.getSharedPreferences("Heishousp", Context.MODE_PRIVATE);
        edit = sharedPreferences.edit();
    }

    public void put(String key,Object object){
        if (object instanceof String){
            edit.putString(key, (String) object);
        }
        if (object instanceof Integer){
            edit.putInt(key, (Integer) object);
        }
        if (object instanceof Boolean){
            edit.putBoolean(key, (Boolean) object);
        }
        if (object instanceof Float){
            edit.putFloat(key, (Float) object);
        }
        if (object instanceof Long){
            edit.putLong(key, (Long) object);
        }
        edit.commit();
    }


    public SharedPreferences getSharedPreferences() {
        return sharedPreferences;
    }

    static SharedPreferencesUtilise sharedPreferencesUtilise;
    public static SharedPreferencesUtilise getInstance() {
        if (sharedPreferencesUtilise==null){
            sharedPreferencesUtilise=new SharedPreferencesUtilise();
        }
        return sharedPreferencesUtilise;
    }
}
